package net.chenlin.dp.modules.generator.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.Query;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.common.utils.CommonUtils;
import net.chenlin.dp.modules.generator.entity.UserIntegralEntity;
import net.chenlin.dp.modules.generator.dao.UserIntegralMapper;
import net.chenlin.dp.modules.generator.service.UserIntegralService;

/**
 * 用户积分表
 * @author zcl<yczclcn@163.com>
 */
@Service("userIntegralService")
public class UserIntegralServiceImpl implements UserIntegralService {

	@Autowired
	private UserIntegralMapper userIntegralMapper;

    /**
     * 分页查询
     * @param params
     * @return
     */
	@Override
	public Page<UserIntegralEntity> listUserIntegral(Map<String, Object> params) {
		Query query = new Query(params);
		Page<UserIntegralEntity> page = new Page<>(query);
		userIntegralMapper.listForPage(page, query);
		return page;
	}

    /**
     * 新增
     * @param userIntegral
     * @return
     */
	@Override
	public R saveUserIntegral(UserIntegralEntity userIntegral) {
		int count = userIntegralMapper.save(userIntegral);
		return CommonUtils.msg(count);
	}

    /**
     * 根据id查询
     * @param id
     * @return
     */
	@Override
	public R getUserIntegralById(Long id) {
		UserIntegralEntity userIntegral = userIntegralMapper.getObjectById(id);
		return CommonUtils.msg(userIntegral);
	}

    /**
     * 修改
     * @param userIntegral
     * @return
     */
	@Override
	public R updateUserIntegral(UserIntegralEntity userIntegral) {
		int count = userIntegralMapper.update(userIntegral);
		return CommonUtils.msg(count);
	}

    /**
     * 列表
     * @param id
     * @return
     */
	@Override
	public R batchRemove(Long[] id) {
		int count = userIntegralMapper.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
